package com.tensquare.jwt;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

import java.text.SimpleDateFormat;

public class ParseJwt {
    public static void main(String[] args) {
        Claims body = Jwts.parser().setSigningKey("itcast")
                .parseClaimsJws("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2NjYiLCJzdWIiOiLlsI_pqawiLCJpYXQiOjE1NjgyMTUwODV9.C3Whc2W___mueewSW639m139OqvCbzzM9xSOsi97eTM")
                .getBody();
        System.out.println("用户id" + body.getId());
        System.out.println("用户角色" + body.get("admin"));
        System.out.println("用户名" + body.getSubject());
        System.out.println("登录时间" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(body.getIssuedAt()));

    }
}
